eventcontroller: Fix crossing event scopes
authorMatthias Clasen <mclasen@redhat.com>
Fri, 29 May 2020 23:39:15 +0000 (19:39 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 29 May 2020 23:41:39 +0000 (19:41 -0400)
We want to deliver crossing events to controllers
with scope same-native as long as at least one of
the targets is on the same native. As a new approach,
treat out-of-scope targets like NULL, and deliver
crossing events as long as one of the targets is
not NULL.

gtk/gtkeventcontroller.c

index c513ea093d886ce78f13b4769e03438c10f83d24..432990ed914312473073c7d04382732687b72137 100644 (file)
@@ -289,15 +289,28 @@ gtk_event_controller_filter_crossing (GtkEventController    *controller,
                                       const GtkCrossingData *data)
 {
   GtkEventControllerPrivate *priv;
+  GtkWidget *old_target, *new_target;
 
   priv = gtk_event_controller_get_instance_private (controller);
 
   if (priv->widget && !gtk_widget_is_sensitive (priv->widget))
     return TRUE;
 
-  if (priv->limit == GTK_LIMIT_SAME_NATIVE &&
-      (!same_native (priv->widget, data->old_target) ||
-       !same_native (priv->widget, data->new_target)))
+  old_target = data->old_target;
+  new_target = data->new_target;
+
+  if (priv->limit == GTK_LIMIT_SAME_NATIVE)
+    {
+      /* treat out-of-scope targets like NULL */
+
+      if (!same_native (priv->widget, old_target))
+        old_target = NULL;
+
+      if (!same_native (priv->widget, new_target))
+        new_target = NULL;
+    }
+
+  if (old_target == NULL && new_target == NULL)
     return TRUE;
 
   return FALSE;